package com.season.seasonStudy.javase.j_021_io;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class XNH {

	public static void main(String[] args) throws IOException {
		FileInputStream fis = null;
		DataInputStream dis = null;
		FileOutputStream fos = null;
		DataOutputStream dos = null;
		try {
			fis = new FileInputStream("E:/wohenshuai/Royma.jpg");
			dis = new DataInputStream(fis);


			fos = new FileOutputStream("E:/Royma1.jpg"); //不存在 自动创建一个空的文件
			dos = new DataOutputStream(fos);

//			dis.read();
//	
//			dos.write();
			int a= 0;
			try {
				a=dis.read();
				while (a!=-1) {
					dos.write(a);
					a=dis.read();
				}
				
				
				
			} catch (Exception e) {
				// TODO: handle exception
			}
			
			
			
			if (dis.read() != 0) {
				
			}

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			fis.close();
			dis.close();
			fos.close();
			dos.close();
		}
	}
}
